function ccR_Priest_CheckForMissingPain()
	local x
	if # tblPGetNearbyEnemies > 0 then
		for x = 0, # tblPGetNearbyEnemies do
			local obj = tblPGetNearbyEnemies[x]
			local vSpell = {GetSpellInfo("Shadow Word: Pain")}
			if obj
			and obj:Exists()
			and (obj:IsTappedByPlayer() or (obj:GetTarget():Exists() and obj:GetTarget():GetName() == ccrPlayerName()))
			and obj:GetAura(vSpell[1]) == nil
			and Player:IsFacing(obj)
			and SpellCanAttack("Shadow Word: Pain", obj)
			then
				return true
			end
		end
	else
		return false
	end					
end

function ccR_Priest_ApplyMissingPain()
	local x
	if # tblPGetNearbyEnemies > 0 then
		for x = 0, # tblPGetNearbyEnemies do
			local obj = tblPGetNearbyEnemies[x]
			local vSpell = {GetSpellInfo("Shadow Word: Pain")}
			if obj
			and obj:Exists()
			and (obj:IsTappedByPlayer() or (obj:GetTarget():Exists() and obj:GetTarget():GetName() == ccrPlayerName()))
			and obj:GetAura(vSpell[1]) == nil
			and Player:IsFacing(obj)
			and SpellCanAttack("Shadow Word: Pain", obj)
			then
				obj:CastSpellByName(GetSpellInfo("Shadow Word: Pain"))
				return
			end
		end
	end
end
function ccR_Priest_CheckForMissingTouch()
	local x
	if # tblPGetNearbyEnemies > 0 then
		for x = 0, # tblPGetNearbyEnemies do
			local obj = tblPGetNearbyEnemies[x]
			local vSpell = {GetSpellInfo("Vampiric Touch")}
			if obj
			and obj:Exists()
			and (obj:IsTappedByPlayer() or (obj:GetTarget():Exists() and obj:GetTarget():GetName() == ccrPlayerName()))
			and obj:GetAura(vSpell[1]) == nil
			and Player:IsFacing(obj)
			and SpellCanAttack("Vampiric Touch", obj)
			then
				return true
			end
		end
	else
		return false
	end					
end

function ccR_Priest_ApplyMissingTouch()
	local x
	if # tblPGetNearbyEnemies > 0 then
		for x = 0, # tblPGetNearbyEnemies do
			local obj = tblPGetNearbyEnemies[x]
			local vSpell = {GetSpellInfo("Vampiric Touch")}
			if obj
			and obj:Exists()
			and (obj:IsTappedByPlayer() or (obj:GetTarget():Exists() and obj:GetTarget():GetName() == ccrPlayerName()))
			and obj:GetAura(vSpell[1]) == nil
			and Player:IsFacing(obj)
			and SpellCanAttack("Vampiric Touch", obj)
			then
				obj:CastSpellByName(GetSpellInfo("Vampiric Touch"))
				return
			end
		end
	end
end